import java.util.Scanner;

/**
 * Created with IntelliJ IDEA.
 * Description: 牛客网: HJ31 单词倒排
 * <a href="https://www.nowcoder.com/practice/81544a4989df4109b33c2d65037c5836?tpId=37&tqId=38366&ru=/exam/oj">...</a>
 * User: DELL
 * Date: 2023-05-16
 * Time: 13:00
 */
public class Main {
    /**
     * 这里就是从后往前遍历,同时使用双指针和 StringBuffer 进行拼接即可
     * @param args
     */
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        while (scanner.hasNext()) {
            String str = scanner.nextLine();
            StringBuffer res = new StringBuffer();
            //从后往前遍历拼接
            int end = str.length();
            for (int i = str.length()-1; i >= 0; i--) {
                if (!isAlpha(str.charAt(i))) {
                    if (i == end-1) {
                        end--;
                    } else {
                        if (res.length()==0) {
                            res.append(str.subSequence(i+1,end));
                        } else {
                            res.append(' ');
                            res.append(str.subSequence(i+1,end));
                        }
                        end = i;
                    }
                }
            }
            //上面的循环会漏掉第一个单词,这里再判断一下
            if (isAlpha(str.charAt(0))) {
                if (res.length()==0) {
                    res.append(str.subSequence(0,end));
                } else {
                    res.append(' ');
                    res.append(str.subSequence(0,end));
                }
            }
            System.out.println(res);
        }
    }

    private static boolean isAlpha(char ch) {
        return (ch >= 'a' && ch <= 'z') || (ch >= 'A' && ch <= 'Z');
    }
}
